//
//  OrderListCell.m
//  StarOrangeStaff
//
//  Created by lshenrong on 2020/7/19.
//  Copyright © 2020 lshenrong. All rights reserved.
//

#import "OrderListCell.h"

@interface OrderListCell ()

@property (nonatomic,strong) UIView *settingBackgroundView;

@property (nonatomic,strong) UILabel *companyLbl;
@property (nonatomic,strong) UILabel *sateLbl;
@property (nonatomic,strong) UILabel *daysLbl;
@property (nonatomic,strong) UILabel *nameLbl;
@property (nonatomic,strong) UILabel *detailLbl;

@property (nonatomic,strong) UIImageView *arrowImgView;
@property (nonatomic,strong) UIImageView *companyImgView;
@property (nonatomic,strong) UIImageView *daysImgView;
@property (nonatomic,strong) UIImageView *nameImgView;
@property (nonatomic,strong) UIImageView *detaiImgView;
@property (nonatomic,strong) CedarButton *phoneBtn;


@property (nonatomic,strong) CedarButton *letfBtn;
@property (nonatomic,strong) CedarButton *rightBtn;

@property (nonatomic,strong) CedarButton *carNumBtn;
@property (nonatomic,strong) CedarButton *dayNumBtn;

@end

@implementation OrderListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self!=nil){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        UIView *lineView = [UIView lineView];
        lineView.backgroundColor = kSeparateLineColor;//
        self.contentView.backgroundColor = kSeparateLineColor;
        [self.contentView addSubview:self.settingBackgroundView];

        [self.settingBackgroundView addSubview:lineView];

        [self.settingBackgroundView addSubview:self.companyImgView];
        [self.settingBackgroundView addSubview:self.daysImgView];
        [self.settingBackgroundView addSubview:self.nameImgView];
        [self.settingBackgroundView addSubview:self.detaiImgView];
        [self.settingBackgroundView addSubview:self.arrowImgView];


        [self.settingBackgroundView addSubview:self.companyLbl];
        [self.settingBackgroundView addSubview:self.sateLbl];
        [self.settingBackgroundView addSubview:self.nameLbl];
        [self.settingBackgroundView addSubview:self.detailLbl];
        [self.settingBackgroundView addSubview:self.daysLbl];

        [self.settingBackgroundView addSubview:self.letfBtn];
        [self.settingBackgroundView addSubview:self.rightBtn];
        [self.settingBackgroundView addSubview:self.phoneBtn];
        [self.settingBackgroundView addSubview:self.carNumBtn];
        [self.settingBackgroundView addSubview:self.dayNumBtn];



        
        [self.settingBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
               make.left.mas_equalTo(self.contentView).mas_offset(kMarginOffsetX);
               make.right.mas_equalTo(self.contentView).mas_offset(-kMarginOffsetX);
               make.top.mas_equalTo(self.contentView).mas_offset(0);
               make.bottom.mas_equalTo(self.contentView).mas_offset(0);
        }];
        

        [self.sateLbl mas_makeConstraints:^(MASConstraintMaker *make) {
           make.right.mas_equalTo(self.settingBackgroundView).mas_offset(-kMarginOffsetX);
           make.top.mas_equalTo(self.settingBackgroundView).mas_offset(kMarginOffsetX);
        }];

        [self.companyImgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.settingBackgroundView).mas_offset(kMarginOffsetX);
            make.top.mas_equalTo(self.settingBackgroundView).mas_offset(kMarginOffsetX);
            make.width.mas_equalTo(21);
            make.height.mas_equalTo(18);
        }];

        [self.companyLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.companyImgView.mas_right).mas_offset(10);
            make.top.mas_equalTo(self.self.companyImgView);
        }];
        
        
        

        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.settingBackgroundView).mas_offset(kMarginOffsetX);
            make.right.mas_equalTo(self.settingBackgroundView).mas_offset(-kMarginOffsetX);
            make.top.mas_equalTo(50);
            make.height.mas_offset(0.5);
        }];

        [self.daysImgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.settingBackgroundView).mas_offset(kMarginOffsetX);
            make.top.mas_equalTo(lineView.mas_bottom).mas_offset(kMarginOffsetX);
            make.width.mas_equalTo(15);
            make.height.mas_equalTo(15);
        }];
        
        [self.daysLbl  mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.daysImgView.mas_right).mas_offset(10);
            make.centerY.mas_equalTo(self.self.daysImgView);
        }];
        
        [self.carNumBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.daysLbl.mas_right).mas_offset(kMarginOffsetX);
            make.centerY.mas_equalTo(self.daysLbl.mas_centerY);
              make.size.mas_equalTo(CGSizeMake(30, 15));
        }];
        
        [self.dayNumBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.carNumBtn.mas_right).mas_offset(kMarginOffsetX);
            make.centerY.mas_equalTo(self.daysLbl.mas_centerY);
            make.size.mas_equalTo(CGSizeMake(30, 15));
        }];
        

        [self.nameImgView mas_makeConstraints:^(MASConstraintMaker *make) {
               make.left.mas_equalTo(self.settingBackgroundView).mas_offset(kMarginOffsetX);
                make.top.mas_equalTo(self.daysImgView.mas_bottom).mas_offset(20);
               make.width.mas_equalTo(15);
               make.height.mas_equalTo(15);
        }];
        
        [self.nameLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.nameImgView.mas_right).mas_offset(10);
            make.centerY.mas_equalTo(self.self.nameImgView);
        }];
        
        [self.phoneBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.nameLbl.mas_right).mas_offset(kMarginOffsetX);
            make.centerY.mas_equalTo(self.nameImgView.mas_centerY);
            make.size.mas_equalTo(CGSizeMake(16, 16 ));;
        }];
      
        [self.detaiImgView mas_makeConstraints:^(MASConstraintMaker *make) {
               make.left.mas_equalTo(self.settingBackgroundView).mas_offset(kMarginOffsetX);
                make.top.mas_equalTo(self.nameImgView.mas_bottom).mas_offset(20);
               make.width.mas_equalTo(15);
               make.height.mas_equalTo(15);
        }];
        [self.detailLbl mas_makeConstraints:^(MASConstraintMaker *make) {
             make.left.mas_equalTo(self.detaiImgView.mas_right).mas_offset(10);
                make.centerY.mas_equalTo(self.self.detaiImgView);
        }];
        
        [self.rightBtn mas_makeConstraints:^(MASConstraintMaker *make) {
              make.right.mas_equalTo(self.settingBackgroundView).mas_offset(-kMarginOffsetX);
            make.bottom.mas_equalTo(self.settingBackgroundView.mas_bottom).mas_offset(-10);
              make.size.mas_equalTo(CGSizeMake(80, 30));;
        }];
        
        [self.letfBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.rightBtn.mas_left).mas_offset(-kMarginOffsetX);
            make.bottom.mas_equalTo(self.settingBackgroundView.mas_bottom).mas_offset(-10);
              make.size.mas_equalTo(CGSizeMake(80, 30));;
        }];
        
    }
    return self;
}


- (void)updateCellData:(id)data{ }


//- (void)testData{
//    self.titleLbl.text = @"航交所连上收益权一号";
//    self.moneyRateLbl.text = @"9.9%+12%";
//    self.daysLbl.text = @"30天";
//    self.moneyRateDetailsLbl.text = @"一次性还本付息";
//    self.surplusMoneyLbl.text = @"剩余1000000000元";
//    self.surplusPersonLbl.text = @"剩余150人";
//}

//- (void)clickAction{
//    if (self.selectCellBlock) {
//        self.selectCellBlock(self.prodoctItem);
//    }
//}
//
- (CedarButton *)letfBtn{
    if (!_letfBtn) {
        _letfBtn = [CedarButton buttonWithOrderText:@"确认接单"];
        [_letfBtn addTarget:self action:@selector(clickAction) forControlEvents:UIControlEventTouchUpInside];
        [_letfBtn PFCGStyleFontSize:13];
        [_letfBtn cornerRadiusStyle:15];
    }
    return _letfBtn;
}

- (CedarButton *)carNumBtn{
    if (!_carNumBtn) {
        _carNumBtn = [CedarButton buttonWithOrderText:@"1辆"];
        [_carNumBtn addTarget:self action:@selector(clickAction) forControlEvents:UIControlEventTouchUpInside];
        [_carNumBtn PFCGStyleFontSize:10];
        [_carNumBtn cornerRadiusStyle:3];
    }
    return _carNumBtn;
}

- (CedarButton *)dayNumBtn{
    if (!_dayNumBtn) {
        _dayNumBtn = [CedarButton buttonWithOrderText:@"1天"];
        [_dayNumBtn addTarget:self action:@selector(clickAction) forControlEvents:UIControlEventTouchUpInside];
         [_dayNumBtn PFCGStyleFontSize:10];
         [_dayNumBtn cornerRadiusStyle:3];
    }
    return _dayNumBtn;
}

- (CedarButton *)rightBtn{
    if (!_rightBtn) {
        _rightBtn = [CedarButton buttonWithOrderText:@"发布任务"];
        [_rightBtn addTarget:self action:@selector(clickAction) forControlEvents:UIControlEventTouchUpInside];
        [_rightBtn PFCGStyleFontSize:13];
        [_rightBtn cornerRadiusStyle:15];
    }
    return _rightBtn;
}

- (CedarButton *)phoneBtn{
    if (!_phoneBtn) {
        _phoneBtn = [CedarButton buttonWithImageName:@"order_phone"];
        
    }
    return _phoneBtn;
}

- (UIView *)settingBackgroundView{
    if (!_settingBackgroundView) {
        _settingBackgroundView = [[UIView alloc]init];
        _settingBackgroundView.backgroundColor = [UIColor whiteColor];
        _settingBackgroundView.layer.cornerRadius = 4;
        _settingBackgroundView.clipsToBounds = YES;
    }
    return _settingBackgroundView;
}

MACRO_UILabel_LazyloadWithPFCGFont(companyLbl, @"公司", kBlackColor, 15)
MACRO_UILabel_LazyloadWithPFCGFont(sateLbl, @"在进行", kOrangeColor, 15)
MACRO_UILabel_LazyloadWithPFCGFont(daysLbl, @"日期",kBlackColor, 15)
MACRO_UILabel_LazyloadWithPFCGFont(nameLbl, @"姓名", kBlackColor, 15)
MACRO_UILabel_LazyloadWithPFCGFont(detailLbl, @"详情", kBlackColor, 15)


MACRO_UIImageView(arrowImgView, @"commen_arrow")
MACRO_UIImageView(companyImgView, @"order_company")
MACRO_UIImageView(nameImgView, @"order_contact")
MACRO_UIImageView(detaiImgView, @"order_trip")
MACRO_UIImageView(daysImgView, @"order_time")



@end
